<template>
	<view class="container">
		<block v-for="(item,index) in menuList" :key="index">
			<tui-collapse :index="index" :current="current" @click="change">
				<template v-slot:title>
					<tui-list-cell :size="32" :hover="false">{{item.name}}</tui-list-cell>
				</template>
				<template v-slot:content>
					<block  v-for="(itm,idx) in item.children" :key="idx">
						<tui-list-cell padding="26rpx 34rpx" color="#666" arrow @click="goto(itm.path)">
							{{itm.name}}
							
							<tui-tag @click.stop padding="8rpx 10rpx" margin="0 20rpx"><tui-link @click.stop  color="#ffffff" :href="weburl+itm.path+'.vue'">源码地址</tui-link></tui-tag>
						</tui-list-cell>
					</block>
				</template>
			</tui-collapse>
		</block>
	</view>
</template>

<script>
	import dataList from './index.js'
	export default {
		data() {
			return {
				menuList: dataList.menuList,
				weburl: dataList.weburl,
				current: -1,
				sweixin: null
			};
		},
		onLoad() {
		},
		watch: {
		},
		methods: {
			goto(path){
				uni.$utils.goto(path)
			},
			change(e) {
				//可关闭自身
				this.current = this.current == e.index ? -1 : e.index
			},
			// change(e) {
			//   		let index = e.index;
			//   		let item = this.dataList[index];
			//   		item.current = item.current == index ? -1 : index
			//   	},
			openThorUI() {
				// #ifdef MP-WEIXIN
				wx.navigateToMiniProgram({
					appId: 'wxb6a98ca343f57a38'
				});
				// #endif

				// #ifndef  MP-WEIXIN
				if (this.sweixin) {
					this.sweixin.launchMiniProgram({
						id: 'gh_0c07a8c02dac'
					});
				} else {
					uni.previewImage({
						urls: ['https://thorui.cn/img/applets.jpg']
					});
				}
				// #endif
			},
			doc() {
				this.tui.href('/pages/my/doc/doc');
			}
		},
		onShareAppMessage: function(e) {
			return {
				title: 'ThorUI示例'
			};
		}
	};
</script>

<style lang="scss">
	.container {
		.tui-content {
			padding: 20rpx 30rpx;
			background-color: #fff;
			color: #555;
			font-size: 26rpx;
		}
	}
</style>